<div class="row">
    <div class="col-xs-12 col-md-12">
        <div class="widget">
            <div class="widget-header ">
                <span class="widget-caption">指令查询</span>

                <div class="widget-buttons">
                    <a href="" widget-maximize></a>
                    <a href="" widget-collapse></a>
                    <a href="" widget-dispose></a>
                </div>
            </div>
            <div class="widget-body" ng-controller="QueryOrdersCtrl as queryCtrl">
                <div class="dataTables_filter">
                    <label>
                    <span class="input-icon">
                        <input type="search" class="input-sm"
                               ng-model='queryCtrl.filterValue' ng-change='queryCtrl.filter()'/>
                        <i class="glyphicon glyphicon-search primary"></i>
                    </span>
                    </label>
                </div>
                <div ui-grid="queryCtrl.queryOrdersOptions" ui-grid-expandable ui-grid-auto-resize
                     style="height: 400px;"></div>
            </div>
        </div>
    </div>
</div>

<script type="text/ng-template" id="orderDetail.html">
    <table class="table table-striped table-bordered" ng-controller="ModalCtrl as modalCtrl">
        <thead>
        <tr>
            <th>指令序号</th>
            <th>指令内容</th>
            <!--<th ng-show="hasRole('ROLE_ADMIN')">操作</th>-->
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="order in row.entity.command.clientCommandList">
            <td>{{order.index}}</td>
            <td>
                <table class="table">
                    <tr>
                        <td>版本号</td>
                        <td>{{order.version}}</td>
                        <td>数据中心</td>
                        <td>{{order.dc}}</td>
                    </tr>
                    <tr>
                        <td>Service接口类名</td>
                        <td colspan="3">{{order.pattern}}</td>
                    </tr>
                    <tr>
                        <td>流量去向</td>
                        <td>
                            <ul style="padding-left: 0; margin-bottom: 0;">
                                <li style="list-style-type:none;"
                                    ng-repeat="group in order.mergeGroups">
                                    {{group}}
                                </li>
                            </ul>
                        </td>
                        <td>路由规则</td>
                        <td>
                            <ul style="padding-left: 0; margin-bottom: 0;">
                                <li style="list-style-type:none;" ng-repeat="rule in order.routeRules">
                                    {{rule}}
                                </li>
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <td>备注</td>
                        <td colspan="3">{{order.remark}}</td>
                    </tr>
                </table>
            </td>
            <!--<td ng-show="hasRole('ROLE_ADMIN')">-->
            <td>
                <a href class="btn" ng-click="modalCtrl.updateModal(row.entity.group,order)">修改</a>
                <a href class="btn btn-danger"
                   ng-click="modalCtrl.deleteModal(row.entity.group,order)">删除</a>
            </td>
        </tr>
        </tbody>
    </table>
</script>

<script type="text/ng-template" id="updateModal.html">
    <div class="modal-header">
        <h3 class="modal-title">指令修改</h3>
    </div>
    <div class="modal-body" ng-controller="ModalCtrl as modalCtrl">
        <table class="table table-striped table-bordered">
            <tr>
                <td>Group</td>
                <td>{{$root.group}}</td>
                <td>指令序号</td>
                <td>{{$root.order.index}}</td>
            </tr>
            <tr>
                <td>版本号</td>
                <td><input type="text" ng-model="$root.order.version" style="width:100%"/></td>
                <td>数据中心</td>
                <td><input type="text" ng-model="$root.order.dc" style="width:100%"/></td>
            </tr>
            <tr>
                <td>Service接口类名</td>
                <td colspan="3"><input type="text" ng-model="$root.order.pattern" style="width:100%"/></td>
            </tr>
            <tr>
                <td>流量去向</td>
                <td>
                    <ul style="padding-left: 0; margin-bottom: 0;">
                        <li style="list-style-type:none;"
                            ng-repeat="group in $root.order.mergeGroups">
                            <input type="text" ng-model="$root.order.mergeGroups[$index]" style="width:100%"/>
                        </li>
                    </ul>
                </td>
                <td>路由规则</td>
                <td>
                    <ul style="padding-left: 0; margin-bottom: 0;">
                        <li style="list-style-type:none;" ng-repeat="rule in $root.order.routeRules">
                            <input type="text" ng-model="$root.order.routeRules[$index]" style="width:100%"/>
                        </li>
                    </ul>
                </td>
            </tr>
            <tr>
                <td>备注</td>
                <td colspan="3"><input type="text" ng-model="$root.order.remark" style="width:100%"/></td>
            </tr>
        </table>
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
        <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
    </div>
</script>

<script type="text/ng-template" id="deleteModal.html">
    <div class="modal-header">
        <h3 class="modal-title">是否确认删除以下指令？</h3>
    </div>
    <div class="modal-body" ng-controller="ModalCtrl as modalCtrl">
        {{$root.order}}
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
        <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
    </div>
</script>

<script type="text/ng-template" id="operationSuccess.html">
    <div class="modal-header">
        <h3 class="modal-title">操作成功！</h3>
    </div>
    <div class="modal-body">
        操作已生效，刷新页面后查询
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" type="button" ng-click="cancel()">返回</button>
        <button class="btn btn-primary" type="button" ng-click="ok()">查询指令</button>
    </div>
</script>

<script type="text/ng-template" id="operationFailed.html">
    <div class="modal-header">
        <h3 class="modal-title">操作失败！</h3>
    </div>
    <div class="modal-body">
        指令操作失败，请咨询管理员
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" type="button" ng-click="cancel()">返回</button>
    </div>
</script>